<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title><?php echo ($meta_title); ?>|OneThink管理平台</title>
    <link href="/Fund/Public/favicon.ico" type="image/x-icon" rel="shortcut icon">
    <link rel="stylesheet" type="text/css" href="/Fund/Public/Admin/css/base.css" media="all">
    <link rel="stylesheet" type="text/css" href="/Fund/Public/Admin/css/common.css" media="all">
    <link rel="stylesheet" type="text/css" href="/Fund/Public/Admin/css/module.css">
    <link rel="stylesheet" type="text/css" href="/Fund/Public/Admin/css/style.css" media="all">
	<link rel="stylesheet" type="text/css" href="/Fund/Public/Admin/css/<?php echo (C("COLOR_STYLE")); ?>.css" media="all">
     <!--[if lt IE 9]>
    <script type="text/javascript" src="/Fund/Public/static/jquery-1.10.2.min.js"></script>
    <![endif]--><!--[if gte IE 9]><!-->
    <script type="text/javascript" src="/Fund/Public/static/jquery-2.0.3.min.js"></script>
    <script type="text/javascript" src="/Fund/Public/Admin/js/jquery.mousewheel.js"></script>
    <!--<![endif]-->
    
	<link href="/Fund/Public/static/jquery-datetimepicker/jquery-datetimepicker.css" rel="stylesheet" media="screen">

</head>
<body>
    <!-- 头部 -->
    <div class="header">
        <!-- Logo -->
        <span class="logo"></span>
        <!-- /Logo -->

        <!-- 主导航 -->
        <ul class="main-nav">
            <?php if(is_array($__MENU__["main"])): $i = 0; $__LIST__ = $__MENU__["main"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$menu): $mod = ($i % 2 );++$i;?><li class="<?php echo ((isset($menu["class"]) && ($menu["class"] !== ""))?($menu["class"]):''); ?>"><a href="<?php echo (U($menu["url"])); ?>"><?php echo ($menu["title"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
        </ul>
        <!-- /主导航 -->

        <!-- 用户栏 -->
        <div class="user-bar">
            <a href="javascript:;" class="user-entrance"><i class="icon-user"></i></a>
            <ul class="nav-list user-menu hidden">
                <li class="manager">你好，<em title="<?php echo session('user_auth.username');?>"><?php echo session('user_auth.username');?></em></li>
                <li><a href="<?php echo U('User/updatePassword');?>">修改密码</a></li>
                <li><a href="<?php echo U('User/updateNickname');?>">修改昵称</a></li>
                <li><a href="<?php echo U('Public/logout');?>">退出</a></li>
            </ul>
        </div>
    </div>
    <!-- /头部 -->

    <!-- 边栏 -->
    <div class="sidebar">
        <!-- 子导航 -->
        
            <div id="subnav" class="subnav">
                <?php if(!empty($_extra_menu)): ?>
                    <?php echo extra_menu($_extra_menu,$__MENU__); endif; ?>
                <?php if(is_array($__MENU__["child"])): $i = 0; $__LIST__ = $__MENU__["child"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$sub_menu): $mod = ($i % 2 );++$i;?><!-- 子导航 -->
                    <?php if(!empty($sub_menu)): if(!empty($key)): ?><h3><i class="icon icon-unfold"></i><?php echo ($key); ?></h3><?php endif; ?>
                        <ul class="side-sub-menu">
                            <?php if(is_array($sub_menu)): $i = 0; $__LIST__ = $sub_menu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$menu): $mod = ($i % 2 );++$i;?><li>
                                    <a class="item" href="<?php echo (U($menu["url"])); ?>"><?php echo ($menu["title"]); ?></a>
                                </li><?php endforeach; endif; else: echo "" ;endif; ?>
                        </ul><?php endif; ?>
                    <!-- /子导航 --><?php endforeach; endif; else: echo "" ;endif; ?>
            </div>
        
        <!-- /子导航 -->
    </div>
    <!-- /边栏 -->

    <!-- 内容区 -->
    <div id="main-content">
        <div id="top-alert" class="fixed alert alert-error" style="display: none;">
            <button class="close fixed" style="margin-top: 4px;">&times;</button>
            <div class="alert-content">这是内容</div>
        </div>
        <div id="main" class="main">
            
            <!-- nav -->
            <?php if(!empty($_show_nav)): ?><div class="breadcrumb">
                <span>您的位置:</span>
                <?php $i = '1'; ?>
                <?php if(is_array($_nav)): foreach($_nav as $k=>$v): if($i == count($_nav)): ?><span><?php echo ($v); ?></span>
                    <?php else: ?>
                    <span><a href="<?php echo ($k); ?>"><?php echo ($v); ?></a>&gt;</span><?php endif; ?>
                    <?php $i = $i+1; endforeach; endif; ?>
            </div><?php endif; ?>
            <!-- nav -->
            

            
    <div class="main-title">
        <h2><?php echo ($_title); ?></h2>
    </div>
    <?php if(!empty($fund)): ?><form action="<?php echo U('Fund/editFund');?>" method="post" class="form-horizontal">
    		<input type="hidden" name="id" value="<?php echo ($fund["id"]); ?>" />
    <?php else: ?>
	    <form action="<?php echo U('Fund/addFund');?>" method="post" class="form-horizontal"><?php endif; ?>
        <!--<div class="form-item">-->
            <!--<label class="item-label">国家地区及代码<span class="check-tips"></span></label>-->
            <!--<div class="controls">-->
                <!--<select name="country_code" class="input-large">-->
            		<!--<?php if(is_array(C("COUNTRY_CODE"))): foreach(C("COUNTRY_CODE") as $key=>$val): ?>-->
	            		<!-- -->
	            		<!--<?php if(!empty($fund)): ?>-->
		            		<!--<?php if($key == $fund['country_code']): ?>-->
			           		<!--<option value="<?php echo ($key); ?>" selected><?php echo ($val); ?></option>-->
				           	<!--<?php else: ?>-->
		            			<!--<option value="<?php echo ($key); ?>"><?php echo ($val); ?></option>-->
		            		<!--<?php endif; ?>-->
            			<!--<?php else: ?>-->
            				<!--<option value="<?php echo ($key); ?>"><?php echo ($val); ?></option>-->
            			<!--<?php endif; ?>-->
            			<!-- -->
            		<!--<?php endforeach; endif; ?>-->
            	<!--</select>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="form-item">-->
            <!--<label class="item-label">基金代码<span class="check-tips">（证券投资基金所在的交易所公布的代码）</span></label>-->
            <!--<div class="controls">-->
            	<!--<input type="text" class="text input-large" name="fund_code" value="<?php echo ((isset($fund["fund_code"]) && ($fund["fund_code"] !== ""))?($fund["fund_code"]):''); ?>"/>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="form-item">-->
            <!--<label class="item-label">基金简称<span class="check-tips">（以交易所公布的基金简称为准）</span></label>-->
            <!--<div class="controls">-->
            	<!--<input type="text" class="text input-large" name="fund_abb" value="<?php echo ((isset($fund["fund_abb"]) && ($fund["fund_abb"] !== ""))?($fund["fund_abb"]):''); ?>"/>-->
            <!--</div>-->
        <!--</div>-->
        <div class="form-item">
            <label class="item-label">基金名称<span class="check-tips">（以交易所公布的基金名称为准）</span></label>
            <div class="controls">
            	<input type="text" class="text input-large" name="fund_name" value="<?php echo ((isset($fund["fund_name"]) && ($fund["fund_name"] !== ""))?($fund["fund_name"]):''); ?>"/>
            </div>
        </div>
        
        <!--<div class="form-item">-->
            <!--<label class="item-label">区域代码<span class="check-tips">（用于标识基金的上市地点）</span></label>-->
            <!--<div class="controls">-->
            	 <!--<select name="section_code" class="input-large">-->
            		<!--<?php if(is_array(C("FUND_SECTION_CODE"))): foreach(C("FUND_SECTION_CODE") as $key=>$val): ?>-->
            			<!--<?php if(!empty($fund)): ?>-->
		            		<!--<?php if($key == $fund['section_code']): ?>-->
				           		<!--<option value="<?php echo ($key); ?>" selected><?php echo ($val); ?></option>-->
				           	<!--<?php else: ?>-->
		            			<!--<option value="<?php echo ($key); ?>"><?php echo ($val); ?></option>-->
		            		<!--<?php endif; ?>-->
            			<!--<?php else: ?>-->
            				<!--<option value="<?php echo ($key); ?>"><?php echo ($val); ?></option>-->
            			<!--<?php endif; ?>-->
            		<!--<?php endforeach; endif; ?>-->
            	<!--</select>-->
            <!--</div>-->
        <!--</div>-->
        
        <div class="form-item">
            <label class="item-label">基金类型<span class="check-tips"></span></label>
            <div class="controls">
            	 <select name="fund_type" class="input-large">
            		<?php if(is_array(C("FUND_TYPE"))): foreach(C("FUND_TYPE") as $key=>$val): if(!empty($fund)): if($key == $fund['fund_type']): ?><option value="<?php echo ($key); ?>" selected><?php echo ($val); ?></option>
				           	<?php else: ?>
		            			<option value="<?php echo ($key); ?>"><?php echo ($val); ?></option><?php endif; ?>
            			<?php else: ?>
            				<option value="<?php echo ($key); ?>"><?php echo ($val); ?></option><?php endif; endforeach; endif; ?>
            	</select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">基金产品合同<span class="check-tips"></span></label>
            <div class="controls">
            	 <select name="contract_id" id="contract_id" class="input-large">
            	 	<option value="0">请选择</option>
            		<?php if(is_array($contractList)): foreach($contractList as $key=>$val): if(!empty($fund)): if($val['id'] == $fund['contract_id']): ?><option value="<?php echo ($val['id']); ?>" selected><?php echo ($val["name"]); ?></option>
				           	<?php else: ?>
		            			<option value="<?php echo ($val['id']); ?>"><?php echo ($val["name"]); ?></option><?php endif; ?>
            			<?php else: ?>
            				<option value="<?php echo ($val['id']); ?>"><?php echo ($val["name"]); ?></option><?php endif; endforeach; endif; ?>
            	</select>
            	<input type="hidden" name="contract_name" id="contract_name" value="<?php echo ((isset($fund["contract_name"]) && ($fund["contract_name"] !== ""))?($fund["contract_name"]):''); ?>"/>
            </div>
        </div>
        
        <div class="form-item">
            <label class="item-label">基金经理<span class="check-tips"></span></label>
            <div class="controls">
            	 <select name="trader_id" id="trader_id" class="input-large">
            	 	<option value="0" selected>请选择</option>
            		<?php if(is_array($traderList)): foreach($traderList as $key=>$val): if(!empty($fund)): if($val['id'] == $fund['trader_id']): ?><option value="<?php echo ($val['id']); ?>" selected><?php echo ($val["name"]); ?></option>
				           	<?php else: ?>
		            			<option value="<?php echo ($val['id']); ?>"><?php echo ($val["name"]); ?></option><?php endif; ?>
            			<?php else: ?>
            				<option value="<?php echo ($val['id']); ?>"><?php echo ($val["name"]); ?></option><?php endif; endforeach; endif; ?>
            	</select>
            	
            	<input type="hidden" name="trader_name" id="trader_name" value="<?php echo ((isset($fund["trader_name"]) && ($fund["trader_name"] !== ""))?($fund["trader_name"]):''); ?>"/>
            </div>
        </div>
        
        <!--<div class="form-item">-->
            <!--<label class="item-label">基金分类<span class="check-tips"></span></label>-->
            <!--<div class="controls">-->
            	<!--<span id="cat_names"></span>-->
            	<!--<span id="cat_sel_p"></span>-->
            	<!--<span id="cat_sel_s"></span>-->
            <!--</div>-->
            <!--<input type="hidden" name="cat_ids" id="cat_ids" value=""/>-->
            <!--<input type="hidden" name="cat_names" id="cat_names1" value=""/>-->
        <!--</div>-->
        <!-- -->
        <div class="form-item">
            <label class="item-label">成分股标题<span class="check-tips"></span></label>
            <div class="controls">
            	<input type="text" class="text input-large" name="avatar_title" value="<?php echo ((isset($fund["avatar_title"]) && ($fund["avatar_title"] !== ""))?($fund["avatar_title"]):''); ?>"/>
            </div>
        </div>
	<div class="form-item">
		<label class="item-label">成分股内容<span class="check-tips"></span></label>
		<div class="controls">
			<textarea style="width:900px;height:200px;padding:5px;" class="input-large" name="avatar_content"><?php echo ((isset($fund["avatar_content"]) && ($fund["avatar_content"] !== ""))?($fund["avatar_content"]):''); ?></textarea>
		</div>
	</div>
        <!-- -->
        <!--<div class="form-item">-->
            <!--<label class="item-label">基金托管费率<span class="check-tips"></span></label>-->
            <!--<div class="controls">-->
            	<!--<input type="text" class="text input-large" name="trusteeship_rate" value="<?php echo ((isset($fund["trusteeship_rate"]) && ($fund["trusteeship_rate"] !== ""))?($fund["trusteeship_rate"]):''); ?>"/> %-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="form-item">-->
            <!--<label class="item-label">基金管理人<span class="check-tips"></span></label>-->
            <!--<div class="controls">-->
            	<!--<input type="text" class="text input-large" name="fund_admin" value="<?php echo ((isset($fund["fund_admin"]) && ($fund["fund_admin"] !== ""))?($fund["fund_admin"]):''); ?>"/>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="form-item">-->
            <!--<label class="item-label">管理费率<span class="check-tips"></span></label>-->
            <!--<div class="controls">-->
            	<!--<input type="text" class="text input-large" name="admin_rate" value="<?php echo ((isset($fund["admin_rate"]) && ($fund["admin_rate"] !== ""))?($fund["admin_rate"]):''); ?>"/> %-->
            <!--</div>-->
        <!--</div>-->
        <div class="form-item">
            <label class="item-label">基金预期收益率<span class="check-tips"></span></label>
            <div class="controls">
            	<input type="text" class="text input-large" name="expected_rate" value="<?php echo ((isset($fund["expected_rate"]) && ($fund["expected_rate"] !== ""))?($fund["expected_rate"]):''); ?>"/> %
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">预期收益率说明<span class="check-tips"></span></label>
            <div class="controls">
            	<textarea style="width:900px;height:200px;padding:5px;" class="input-large" name="expected_rate_desc"><?php echo ((isset($fund["expected_rate_desc"]) && ($fund["expected_rate_desc"] !== ""))?($fund["expected_rate_desc"]):''); ?></textarea>
            </div>
        </div>
        <!--<div class="form-item">-->
            <!--<label class="item-label">证券投资基金成立时间<span class="check-tips">（基金产品发行时间）</span></label>-->
            <!--<div class="controls">-->
            	<!--<input type="text" class="text input-large date_picker" name="estb_time" value="<?php echo ((isset($fund["estb_time_format"]) && ($fund["estb_time_format"] !== ""))?($fund["estb_time_format"]):''); ?>"/>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="form-item">-->
            <!--<label class="item-label">证券投资基金上市时间<span class="check-tips"></span></label>-->
            <!--<div class="controls">-->
            	<!--<input type="text" class="text input-large date_picker" name="list_time" value="<?php echo ((isset($fund["list_time_format"]) && ($fund["list_time_format"] !== ""))?($fund["list_time_format"]):''); ?>"/>-->
            <!--</div>-->
        <!--</div>-->
        <div class="form-item">
            <label class="item-label">开放期起始日期<span class="check-tips"></span></label>
            <div class="controls">
            	<input type="text" class="text input-large date_picker" name="open_start_time" value="<?php echo ((isset($fund["open_start_time_format"]) && ($fund["open_start_time_format"] !== ""))?($fund["open_start_time_format"]):''); ?>"/>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">开放期赎回起始日期<span class="check-tips"></span></label>
            <div class="controls">
            	<input type="text" class="text input-large date_picker" name="open_back_time" value="<?php echo ((isset($fund["open_back_time_format"]) && ($fund["open_back_time_format"] !== ""))?($fund["open_back_time_format"]):''); ?>"/>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">开放期结束日期<span class="check-tips"></span></label>
            <div class="controls">
            	<input type="text" class="text input-large date_picker" name="open_end_time" value="<?php echo ((isset($fund["open_end_time_format"]) && ($fund["open_end_time_format"] !== ""))?($fund["open_end_time_format"]):''); ?>"/>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">开放日说明<span class="check-tips"></span></label>
            <div class="controls">
            	<textarea style="width:900px;height:200px;padding:5px;" class="input-large" name="open_desc"><?php echo ((isset($fund["open_desc"]) && ($fund["open_desc"] !== ""))?($fund["open_desc"]):''); ?></textarea>
            </div>
        </div>
         <div class="form-item">
            <label class="item-label">封闭期限<span class="check-tips">（针对封闭式基金而言，指其封闭时间）</span></label>
            <div class="controls">
            	<input type="text" class="text input-large" name="std_time" value="<?php echo ((isset($fund["std_time"]) && ($fund["std_time"] !== ""))?($fund["std_time"]):''); ?>"/>
            	<select name="std_unit">
            		<?php if(is_array($stdUnit)): foreach($stdUnit as $key=>$item): if($fund['std_unit'] == $key): ?><option value="<?php echo ($key); ?>" selected='selected'><?php echo ($item); ?></option>
            			<?php else: ?>
	            			<option value="<?php echo ($key); ?>"><?php echo ($item); ?></option><?php endif; endforeach; endif; ?>
            	</select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">封闭期说明<span class="check-tips"></span></label>
            <div class="controls">
            	<textarea style="width:900px;height:200px;padding:5px;" class="input-large" name="close_desc"><?php echo ((isset($fund["close_desc"]) && ($fund["close_desc"] !== ""))?($fund["close_desc"]):''); ?></textarea>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">总份数<span class="check-tips"></span></label>
            <div class="controls">
            	<input type="text" class="text input-large" name="total_count" value="<?php echo ((isset($fund["total_count"]) && ($fund["total_count"] !== ""))?($fund["total_count"]):''); ?>"/>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">开始购买日期<span class="check-tips"></span></label>
            <div class="controls">
            	<input type="text" class="text input-large date_picker" name="trade_time" value="<?php echo ((isset($fund["trade_time_format"]) && ($fund["trade_time_format"] !== ""))?($fund["trade_time_format"]):''); ?>"/>
            </div>
        </div>
        <!-- <div class="form-item">
            <label class="item-label">最小购买金额<span class="check-tips">（单位元，0表示无限制）</span></label>
            <div class="controls">
            	<input type="text" class="text input-large" name="min_amount" value="<?php echo ((isset($fund["min_amount"]) && ($fund["min_amount"] !== ""))?($fund["min_amount"]):''); ?>"/>
            </div>
        </div> -->
        <div class="form-item">
            <label class="item-label">最小购买份数<span class="check-tips"></span></label>
            <div class="controls">
            	<input type="text" class="text input-large" name="min_count" value="<?php echo ((isset($fund["min_count"]) && ($fund["min_count"] !== ""))?($fund["min_count"]):''); ?>"/>
            </div>
        </div>
        <!-- <div class="form-item">
            <label class="item-label">最大投资金额<span class="check-tips">（单位元，0表示无限制）</span></label>
            <div class="controls">
            	<input type="text" class="text input-large" name="max_amount" value="<?php echo ((isset($fund["max_amount"]) && ($fund["max_amount"] !== ""))?($fund["max_amount"]):''); ?>"/>
            </div>
        </div> -->
        <div class="form-item">
            <label class="item-label">最大购买份数<span class="check-tips"></span></label>
            <div class="controls">
            	<input type="text" class="text input-large" name="max_count" value="<?php echo ((isset($fund["max_count"]) && ($fund["max_count"] !== ""))?($fund["max_count"]):''); ?>"/>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">每份金额<span class="check-tips"></span></label>
            <div class="controls">
            	<input type="text" class="text input-large" name="unit_price" value="<?php echo ((isset($fund["unit_price"]) && ($fund["unit_price"] !== ""))?($fund["unit_price"]):''); ?>"/>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">排序<span class="check-tips">（基金产品的显示顺序，整数，越小越靠前）</span></label>
            <div class="controls">
            	<input type="text" class="text input-large" name="sort_order" value="<?php echo ((isset($fund["sort_order"]) && ($fund["sort_order"] !== ""))?($fund["sort_order"]):''); ?>"/>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">基金产品描述<span class="check-tips"></span></label>
            <div class="controls">
            	<textarea style="width:900px;height:200px;padding:5px;" class="input-large" name="fund_brief"><?php echo ((isset($fund["fund_brief"]) && ($fund["fund_brief"] !== ""))?($fund["fund_brief"]):''); ?></textarea>
            </div>
        </div>
        
        <div class="form-item">
            <label class="item-label">是否是推荐基金产品<span class="check-tips"></span></label>
            <div class="controls">
            	 <select name="is_recommend" class="input-large">
            		<?php if(is_array(C("FUND_RECOMMEND"))): foreach(C("FUND_RECOMMEND") as $key=>$val): if(!empty($fund)): if($key == $fund['is_recommend']): ?><option value="<?php echo ($key); ?>" selected><?php echo ($val); ?></option>
				           	<?php else: ?>
		            			<option value="<?php echo ($key); ?>"><?php echo ($val); ?></option><?php endif; ?>
            			<?php else: ?>
            				<option value="<?php echo ($key); ?>"><?php echo ($val); ?></option><?php endif; endforeach; endif; ?>
            	</select>
            </div>
        </div>
        
        <div class="form-item">
            <label class="item-label">推荐理由<span class="check-tips">（如果是推荐基金产品，需给出推荐理由）</span></label>
            <div class="controls">
            	<textarea style="width:900px;height:200px;padding:5px;" class="input-large" name="recommend_note"><?php echo ((isset($fund["recommend_note"]) && ($fund["recommend_note"] !== ""))?($fund["recommend_note"]):''); ?></textarea>
            </div>
        </div>
        
        <div class="form-item">
            <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>

        </div>
        <div class="cont-ft">
            <div class="copyright">
                <div class="fl">感谢使用<a href="http://www.onethink.cn" target="_blank">OneThink</a>管理平台</div>
                <div class="fr">V<?php echo (ONETHINK_VERSION); ?></div>
            </div>
        </div>
    </div>
    <!-- /内容区 -->
    <script type="text/javascript">
    (function(){
        var ThinkPHP = window.Think = {
            "ROOT"   : "/Fund", //当前网站地址
            "APP"    : "/Fund/admin.php?s=", //当前项目地址
            "PUBLIC" : "/Fund/Public", //项目公共目录地址
            "DEEP"   : "<?php echo C('URL_PATHINFO_DEPR');?>", //PATHINFO分割符
            "MODEL"  : ["<?php echo C('URL_MODEL');?>", "<?php echo C('URL_CASE_INSENSITIVE');?>", "<?php echo C('URL_HTML_SUFFIX');?>"],
            "VAR"    : ["<?php echo C('VAR_MODULE');?>", "<?php echo C('VAR_CONTROLLER');?>", "<?php echo C('VAR_ACTION');?>"]
        }
    })();
    </script>
    <script type="text/javascript" src="/Fund/Public/static/think.js"></script>
    <script type="text/javascript" src="/Fund/Public/Admin/js/common.js"></script>
    <script type="text/javascript">
        +function(){
            var $window = $(window), $subnav = $("#subnav"), url;
            $window.resize(function(){
                $("#main").css("min-height", $window.height() - 130);
            }).resize();

            /* 左边菜单高亮 */
            url = window.location.pathname + window.location.search;
            url = url.replace(/(\/(p)\/\d+)|(&p=\d+)|(\/(id)\/\d+)|(&id=\d+)|(\/(group)\/\d+)|(&group=\d+)/, "");
            $subnav.find("a[href='" + url + "']").parent().addClass("current");

            /* 左边菜单显示收起 */
            $("#subnav").on("click", "h3", function(){
                var $this = $(this);
                $this.find(".icon").toggleClass("icon-fold");
                $this.next().slideToggle("fast").siblings(".side-sub-menu:visible").
                      prev("h3").find("i").addClass("icon-fold").end().end().hide();
            });

            $("#subnav h3 a").click(function(e){e.stopPropagation()});

            /* 头部管理员菜单 */
            $(".user-bar").mouseenter(function(){
                var userMenu = $(this).children(".user-menu ");
                userMenu.removeClass("hidden");
                clearTimeout(userMenu.data("timeout"));
            }).mouseleave(function(){
                var userMenu = $(this).children(".user-menu");
                userMenu.data("timeout") && clearTimeout(userMenu.data("timeout"));
                userMenu.data("timeout", setTimeout(function(){userMenu.addClass("hidden")}, 100));
            });

	        /* 表单获取焦点变色 */
	        $("form").on("focus", "input", function(){
		        $(this).addClass('focus');
	        }).on("blur","input",function(){
				        $(this).removeClass('focus');
			        });
		    $("form").on("focus", "textarea", function(){
			    $(this).closest('label').addClass('focus');
		    }).on("blur","textarea",function(){
			    $(this).closest('label').removeClass('focus');
		    });

            // 导航栏超出窗口高度后的模拟滚动条
            var sHeight = $(".sidebar").height();
            var subHeight  = $(".subnav").height();
            var diff = subHeight - sHeight; //250
            var sub = $(".subnav");
            if(diff > 0){
                $(window).mousewheel(function(event, delta){
                    if(delta>0){
                        if(parseInt(sub.css('marginTop'))>-10){
                            sub.css('marginTop','0px');
                        }else{
                            sub.css('marginTop','+='+10);
                        }
                    }else{
                        if(parseInt(sub.css('marginTop'))<'-'+(diff-10)){
                            sub.css('marginTop','-'+(diff-10));
                        }else{
                            sub.css('marginTop','-='+10);
                        }
                    }
                });
            }
        }();
    </script>
    
	<script type="text/javascript" src="/Fund/Public/static/jquery-datetimepicker/jquery-datetimepicker.js"></script>
    <script type="text/javascript">
    	$(function(){
    		window.fundCatNames = {};
    		window.fundCatIds = {};
    		
    		<?php if(!empty($fund)): ?>//查询基金所属的分类信息
    			var fundId = '<?php echo ($fund["id"]); ?>';
    			var fundCat = ajaxRequest('<?php echo U("Fund/fundCatRelation");?>', {'fund_id':fundId}, {'async':false});
    			var catIds = '';
    			var catNames = '';
    			
    			//初始化基金所属的分类信息
    			if(fundCat && fundCat.error == 0) {
    				$.each(fundCat.msg, function(key, val) {
    					fundCatIds[val['cat_parent_id']] = val['cat_id'];
    					fundCatNames[val['cat_parent_id']] = val['cat_name'];
    					catIds += val['cat_id'] + ',';
    					catNames += val['cat_name'] + ',';
    				});
    				
    				catIds = catIds.substr(0, catIds.length - 1);
        			catNames = catNames.substr(0, catNames.length - 1);
        			$("#cat_ids").val(catIds);
        			$("#cat_names1").val(catNames);
        			$("#cat_names").html('已选择分类：'+catNames);
    			}<?php endif; ?>
    		
    		//请求基金父级分类信息
    		var data = ajaxRequest('<?php echo U("Fund/searchCat");?>', {'parent_id':-1}, {'async':false});
    		var parent = $("#cat_sel_p");
    		
    		if(data && data.error == 0) {
    			//显示父级分类信息
    			var info = '<select><option value="-1">请选择父级分类</option>';
				$.each(data.msg, function(key, val){
					info += '<option value="'+val.id+'">'+val.name+'</option>';
				});
				info += '</select>';
				parent.empty().append(info);
				var child = $("#cat_sel_s");
				
				//父级分类注册事件
				parent.children('select').change(function(){
            		var pVal = $(this).val();
            		if(pVal == -1) {
            			child.empty();
            			return;
            		}
            		
            		//请求基金子级分类信息
            		data = ajaxRequest('<?php echo U("Fund/searchCat");?>', {'parent_id':pVal}, {'async':false});
            		
            		//基金分类信息获取成功
            		if(data.error == 0) {
            			//显示子分类信息
            			info = '<select><option value="-1">请选择子级分类</option>';
        				$.each(data.msg, function(key, val){ 
        					info += '<option value="'+val.id+'">'+val.name+'</option>';
        				});
        				info += '</select>';
        				child.empty().append(info);
    	        		
    	        		//子分类信息注册change事件
    	        		child.children('select').change(function(){
    	        			//已选择分类id
    	        			var ids = window.fundCatIds;
    	        			//已选择分类名称
    	        			var names = window.fundCatNames;
    	        			names[pVal] = child.children('select').find('option:selected').html();
    	        			ids[pVal] = $(this).val();
    	        			
    	        			catNames = '';
    	        			$.each(names, function(key, val){
    	        				catNames += val + ',';
    	        			});

    	        			catIds = '';
    	        			$.each(ids, function(key, val){
    	        				catIds += val + ',';
    	        			});
    	        			
    	        			catIds = catIds.substr(0, catIds.length - 1);
    	        			catNames = catNames.substr(0, catNames.length - 1);
    	        			$("#cat_ids").val(catIds);
    	        			$("#cat_names1").val(catNames);
	        				$("#cat_names").html('已选择分类：'+catNames+'　');
    	        		});
        			} else {
        				child.html(data.msg);
        			} 
            	});
    		} else {
    			parent.html('分类信息查询失败');
    		}
    		
    		//注册基金经理选择事件
    		$("#trader_id").change(function(){
    			var val = $(this).val();
    			var traderName = $("#trader_name");
    			if(val == 0) {
    				traderName.val('');
    				return;
    			}
    			traderName.val($(this).find('option:selected').html());
    		});
    		
    		//注册合同类型选择事件
    		$("#contract_id").change(function(){
    			var val = $(this).val();
    			var contractName = $("#contract_name");
    			if(val == 0) {
    				contractName.val('');
    				return;
    			}
    			contractName.val($(this).find('option:selected').html());
    		});
    	});
    	
    	//日期时间插件
    	$('.date_picker').datetimepicker({
    		lang:'ch',
    		format:'Y-m-d',
    		timepicker:false,
    		allowBlank:true
		});
    	
        //导航高亮
        highlight_subnav('<?php echo U('Fund/fundList');?>');
    </script>

</body>
</html>